package cn.powerone.scm.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.powerone.common.annotation.Log;
import cn.powerone.common.core.controller.BaseController;
import cn.powerone.common.core.domain.AjaxResult;
import cn.powerone.common.enums.BusinessType;
import cn.powerone.scm.domain.ScmStatsSupplierMonthly;
import cn.powerone.scm.service.IScmStatsSupplierMonthlyService;
import cn.powerone.common.utils.poi.ExcelUtil;
import cn.powerone.common.core.page.TableDataInfo;

/**
 * 供应商月度统计信息Controller
 * 
 * @author PowerOne
 * @date 2025-09-09
 */
@RestController
@RequestMapping("/scm/scmStatsSupplierMonthly")
public class ScmStatsSupplierMonthlyController extends BaseController
{
    @Autowired
    private IScmStatsSupplierMonthlyService scmStatsSupplierMonthlyService;

    /**
     * 查询供应商月度统计信息列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsSupplierMonthly:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmStatsSupplierMonthly scmStatsSupplierMonthly)
    {
        startPage();
        List<ScmStatsSupplierMonthly> list = scmStatsSupplierMonthlyService.selectScmStatsSupplierMonthlyList(scmStatsSupplierMonthly);
        return getDataTable(list);
    }

    /**
     * 导出供应商月度统计信息列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsSupplierMonthly:export')")
    @Log(title = "供应商月度统计信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmStatsSupplierMonthly scmStatsSupplierMonthly)
    {
        List<ScmStatsSupplierMonthly> list = scmStatsSupplierMonthlyService.selectScmStatsSupplierMonthlyList(scmStatsSupplierMonthly);
        ExcelUtil<ScmStatsSupplierMonthly> util = new ExcelUtil<ScmStatsSupplierMonthly>(ScmStatsSupplierMonthly.class);
        util.exportExcel(response, list, "供应商月度统计信息数据");
    }

    /**
     * 获取供应商月度统计信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsSupplierMonthly:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmStatsSupplierMonthlyService.selectScmStatsSupplierMonthlyById(id));
    }

    /**
     * 新增供应商月度统计信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsSupplierMonthly:add')")
    @Log(title = "供应商月度统计信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmStatsSupplierMonthly scmStatsSupplierMonthly)
    {
        return toAjax(scmStatsSupplierMonthlyService.insertScmStatsSupplierMonthly(scmStatsSupplierMonthly));
    }

    /**
     * 修改供应商月度统计信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsSupplierMonthly:edit')")
    @Log(title = "供应商月度统计信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmStatsSupplierMonthly scmStatsSupplierMonthly)
    {
        return toAjax(scmStatsSupplierMonthlyService.updateScmStatsSupplierMonthly(scmStatsSupplierMonthly));
    }

    /**
     * 删除供应商月度统计信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmStatsSupplierMonthly:remove')")
    @Log(title = "供应商月度统计信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmStatsSupplierMonthlyService.deleteScmStatsSupplierMonthlyByIds(ids));
    }
}
